/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vetxsoft.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author cuero
 */
@Entity
@Table(name = "HISTORIAS_CLINICAS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HistoriaClinica.findAll", query = "SELECT h FROM HistoriaClinica h"),
    @NamedQuery(name = "HistoriaClinica.findByCodigo", query = "SELECT h FROM HistoriaClinica h WHERE h.codigo = :codigo"),
    @NamedQuery(name = "HistoriaClinica.findByFechaInicioHistoria", query = "SELECT h FROM HistoriaClinica h WHERE h.fechaInicioHistoria = :fechaInicioHistoria")})
public class HistoriaClinica extends EntityStored implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CODIGO")
    private Integer codigo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FECHA_INICIO_HISTORIA")
    @Temporal(TemporalType.DATE)
    private Date fechaInicioHistoria = new Date();
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codHistoriaClinica", fetch = FetchType.LAZY)
    private List<Desparacitacion> desparacitacionList;
    @JoinColumn(name = "COD_MASCOTA", referencedColumnName = "CODIGO")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Mascota codMascota;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codHistoriaClinica", fetch = FetchType.LAZY)
    private List<Consulta> consultaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codHistoriaClinica", fetch = FetchType.LAZY)
    private List<Vacunacion> vacunacionList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codHistoriaClinica", fetch = FetchType.LAZY)
    private List<Cita> citaList;

    public HistoriaClinica() {
    }

    public HistoriaClinica(Integer codigo) {
        this.codigo = codigo;
    }

    public HistoriaClinica(Integer codigo, Date fechaInicioHistoria) {
        this.codigo = codigo;
        this.fechaInicioHistoria = fechaInicioHistoria;
    }

    public Integer getCodigo() {
        return codigo;
    }

    public void setCodigo(Integer codigo) {
        this.codigo = codigo;
    }

    public Date getFechaInicioHistoria() {
        return fechaInicioHistoria;
    }

    public void setFechaInicioHistoria(Date fechaInicioHistoria) {
        this.fechaInicioHistoria = fechaInicioHistoria;
    }

    @XmlTransient
    public List<Desparacitacion> getDesparacitacionList() {
        return desparacitacionList;
    }

    public void setDesparacitacionList(List<Desparacitacion> desparacitacionList) {
        this.desparacitacionList = desparacitacionList;
    }

    public Mascota getCodMascota() {
        return codMascota;
    }

    public void setCodMascota(Mascota codMascota) {
        this.codMascota = codMascota;
    }

    @XmlTransient
    public List<Consulta> getConsultaList() {
        return consultaList;
    }

    public void setConsultaList(List<Consulta> consultaList) {
        this.consultaList = consultaList;
    }

    @XmlTransient
    public List<Vacunacion> getVacunacionList() {
        return vacunacionList;
    }

    public void setVacunacionList(List<Vacunacion> vacunacionList) {
        this.vacunacionList = vacunacionList;
    }

    @XmlTransient
    public List<Cita> getCitaList() {
        return citaList;
    }

    public void setCitaList(List<Cita> citaList) {
        this.citaList = citaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigo != null ? codigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HistoriaClinica)) {
            return false;
        }
        HistoriaClinica other = (HistoriaClinica) object;
        if ((this.codigo == null && other.codigo != null) || (this.codigo != null && !this.codigo.equals(other.codigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + this.codigo + "";
    }
}
